home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
lpmac1.arc
/
MACROS.MLB
< prev
next >
Wrap
Text File
|
1987-03-02
|
13KB
|
1,044 lines
.XCREF SET_MACRO_EXPANSION
SET_MACRO_EXPANSION MACRO
IFNDEF MACRO_EXPANSION_CONTROL
.XALL
ENDIF
IFDEF MACRO_EXPANSION_CONTROL
IF MACRO_EXPANSION_CONTROL EQ 1
.SALL
ELSE
IF MACRO_EXPANSION_CONTROL EQ 2
.LALL
ENDIF
ENDIF
ENDIF
ENDM
IFNDEF TRUE
TRUE EQU 001H
ENDIF
IFNDEF ZFLAG
ZFLAG EQU 00040H
ENDIF
.XCREF REGISTER_TO_SERIAL_FOR_LIST
REGISTER_TO_SERIAL_FOR_LIST MACRO REGISTER, SERIAL, LIST
.XCREF SERIAL_LIST_ITEM
SERIAL_LIST_ITEM = 0
SERIAL = 0
IRP REGISTER_LIST_ITEM, <LIST>
SERIAL_LIST_ITEM = SERIAL_LIST_ITEM + 1
IFIDN <REGISTER>, <REGISTER_LIST_ITEM>
SERIAL = SERIAL_LIST_ITEM
EXITM
ENDIF
ENDM
ENDM
.XCREF REGISTER_TO_SERIAL
REGISTER_TO_SERIAL MACRO REGISTER, SERIAL
REGISTER_TO_SERIAL_FOR_LIST REGISTER, SERIAL, <AX,BX,CX,DX,SI,DI,SP,BP,DS,ES,SS>
IFE SERIAL
REGISTER_TO_SERIAL_FOR_LIST REGISTER, SERIAL, <ax,bx,cx,dx,si,di,sp,bp,ds,es,ss>
ENDIF
ENDM
.XCREF SERIAL_TO_POP_REGISTER
SERIAL_TO_POP_REGISTER MACRO SERIAL
.XCREF UNMATCHED_SERIAL_TO_POP_REGISTER, SERIAL_LIST_ITEM
SERIAL_LIST_ITEM = 0
UNMATCHED_SERIAL_TO_POP_REGISTER = 1
IRP REGISTER_LIST_ITEM, <AX,BX,CX,DX,SI,DI,SP,BP,DS,ES,SS>
SERIAL_LIST_ITEM = SERIAL_LIST_ITEM + 1
IF SERIAL EQ SERIAL_LIST_ITEM
POP REGISTER_LIST_ITEM
UNMATCHED_SERIAL_TO_POP_REGISTER = 0
EXITM
ENDIF
ENDM
IF UNMATCHED_SERIAL_TO_POP_REGISTER
ERROR, BAD SPEC FOR SERIAL_TO_POP_REGISTER
ENDIF
ENDM
.XCREF PHASE_1_REGISTER_STACK_INIT, PHASE_2_REGISTER_STACK_INIT
PHASE_1_REGISTER_STACK_INIT = 1
PHASE_2_REGISTER_STACK_INIT = 1
.XCREF REGISTER_STACK_INIT_IF_NECESSARY
REGISTER_STACK_INIT_IF_NECESSARY MACRO
.XCREF REGISTER_STACK_TOP
IF1
IF PHASE_1_REGISTER_STACK_INIT
REGISTER_STACK_TOP = 0
PHASE_1_REGISTER_STACK_INIT = 0
ENDIF
ENDIF
IF2
IF PHASE_2_REGISTER_STACK_INIT
REGISTER_STACK_TOP = 0
PHASE_2_REGISTER_STACK_INIT = 0
ENDIF
ENDIF
ENDM
.XCREF SAVE_REGISTER_STACK
SAVE_REGISTER_STACK MACRO RS_TOP, VALUE
.XCREF REGISTER_STACK&RS_TOP
REGISTER_STACK&RS_TOP = VALUE
ENDM
.XCREF PUSH_REGISTER_STACK
PUSH_REGISTER_STACK MACRO REGISTER_STACK_VALUE
REGISTER_STACK_INIT_IF_NECESSARY
REGISTER_STACK_TOP = REGISTER_STACK_TOP + 1
SAVE_REGISTER_STACK %REGISTER_STACK_TOP, REGISTER_STACK_VALUE
ENDM
.XCREF PUSH_REGISTER_SERIAL
PUSH_REGISTER_SERIAL MACRO REGISTR, REGISTER_SERIAL
REGISTER_TO_SERIAL REGISTR, REGISTER_SERIAL
IF REGISTER_SERIAL
PUSH REGISTR
PUSH_REGISTER_STACK %REGISTER_SERIAL
ELSE
ERROR, UNABLE TO PUSH REGISTER REGISTR
ENDIF
ENDM
.XCREF REGISTER_STACK_TO_POP_REGISTER
REGISTER_STACK_TO_POP_REGISTER MACRO RS_TOP
SERIAL_TO_POP_REGISTER %(REGISTER_STACK&RS_TOP)
ENDM
.XCREF POP_REGISTER_STACK
POP_REGISTER_STACK MACRO
IF REGISTER_STACK_TOP
REGISTER_STACK_TO_POP_REGISTER %REGISTER_STACK_TOP
REGISTER_STACK_TOP = REGISTER_STACK_TOP - 1
ELSE
ERROR, UNABLE TO POP THE EMPTY REGISTER STACK
ENDIF
ENDM
.XCREF PUSH_REGISTERS,POP_REGISTERS
PUSH_REGISTERS MACRO REGS
.XCREF REGISTER_STACK_COUNT, REGISTER_SERIAL
REGISTER_STACK_COUNT = 0
IRP REG,<REGS>
PUSH_REGISTER_SERIAL REG, REGISTER_SERIAL
IF REGISTER_SERIAL
REGISTER_STACK_COUNT = REGISTER_STACK_COUNT + 1
ENDIF
ENDM
PUSH_REGISTER_STACK %REGISTER_STACK_COUNT
ENDM
.XCREF POP_REGISTER_STACK_COUNT
POP_REGISTER_STACK_COUNT MACRO RS_TOP
REGISTER_STACK_COUNT = REGISTER_STACK&RS_TOP
REGISTER_STACK_TOP = REGISTER_STACK_TOP - 1
ENDM
POP_REGISTERS MACRO
REGISTER_STACK_INIT_IF_NECESSARY
IF REGISTER_STACK_TOP
POP_REGISTER_STACK_COUNT %REGISTER_STACK_TOP
IF REGISTER_STACK_COUNT
REPT REGISTER_STACK_COUNT
POP_REGISTER_STACK
ENDM
ENDIF
ELSE
ERROR, NO REGISTERS LEFT TO POP
ENDIF
ENDM
.XCREF PUSHM,POPM
PUSHM MACRO REGS
IRP REG,<REGS>
PUSH REG
ENDM
ENDM
POPM MACRO REGS
IRP REG,<REGS>
POP REG
ENDM
ENDM
.XCREF GETZ,GETNZ,NOTZ
GETZ MACRO
LOCAL SKIPZ
MOV AL,TRUE
JZ SKIPZ
XOR AL,AL
SKIPZ:
AND AL,AL
ENDM
GETNZ MACRO
LOCAL SKIPNZ
MOV AL,TRUE
JNZ SKIPNZ
XOR AL,AL
SKIPNZ:
ENDM
NOTZ MACRO
LAHF
AND AH,ZFLAG
ENDM
.XCREF JNNC,JNNZ,JNNNZ,JNNE,JNNNE,JNNS,JU,JNU,JNNCXZ
JNNC MACRO LABEL
JC LABEL
ENDM
JNNZ MACRO LABEL
JZ LABEL
ENDM
JNNNZ MACRO LABEL
JNZ LABEL
ENDM
JNNE MACRO LABEL
JE LABEL
ENDM
JNNNE MACRO LABEL
JNE LABEL
ENDM
JNNS MACRO LABEL
JS LABEL
ENDM
JU MACRO LABEL
JMP SHORT LABEL
ENDM
JNU MACRO LABEL
ENDM
JNNCXZ MACRO LABEL
JCXZ LABEL
ENDM
.XCREF JNNB,JNNA
JNNB MACRO LABEL
JB LABEL
ENDM
JNNA MACRO LABEL
JA LABEL
ENDM
.XCREF JNNBE, JNNLE, JNNL, JNNGE, JNNG, JNNO, JNNP, JNPO, JNPE
JNNBE MACRO LABEL
JBE LABEL
ENDM
JNNLE MACRO LABEL
JLE LABEL
ENDM
JNNL MACRO LABEL
JL LABEL
ENDM
JNNGE MACRO LABEL
JGE LABEL
ENDM
JNNG MACRO LABEL
JG LABEL
ENDM
JNNO MACRO LABEL
JO LABEL
ENDM
JNNP MACRO LABEL
JP LABEL
ENDM
JNPO MACRO LABEL
JPE LABEL
ENDM
JNPE MACRO LABEL
JPO LABEL
ENDM
.XCREF SET_SHORT_BACK
SET_SHORT_BACK MACRO BACK_LABEL
.XCREF SHORT_LABEL
SHORT_LABEL = $ - OFFSET BACK_LABEL LE 126
ENDM
.XCREF SET_SHORT_FORWARD
SET_SHORT_FORWARD MACRO FORWARD_LABEL, MAX_BYTES
.XCREF FORWARD_SHORT_LABEL
IF1
FORWARD_SHORT_LABEL = 0
ENDIF
IF2
FORWARD_SHORT_LABEL = OFFSET FORWARD_LABEL - $ LE MAX_BYTES
ENDIF
ENDM
IFDEF LP_DEBUG
.XCREF D_SHORT_LABEL
D_SHORT_LABEL MACRO
.LALL
IF SHORT_LABEL
ELSE
ENDIF
SET_MACRO_EXPANSION
ENDM
ENDIF
.XCREF IS_LONG_NECESSARY
IS_LONG_NECESSARY MACRO FORWARD_LABEL, MAX_BYTES
.XCREF UNNECESSARY_LONG_COMMENTS
SET_SHORT_FORWARD FORWARD_LABEL, MAX_BYTES
IF1
UNNECESSARY_LONG_COMMENTS = 0
ENDIF
IF FORWARD_SHORT_LABEL
.LALL
.SALL
SET_MACRO_EXPANSION
UNNECESSARY_LONG_COMMENTS = 1
ENDIF
ENDM
.XCREF OUT_UNNECESSARY_LONG_COMMENTS
OUT_UNNECESSARY_LONG_COMMENTS MACRO
IFDEF UNNECESSARY_LONG_COMMENTS
IF UNNECESSARY_LONG_COMMENTS
.LALL
.SALL
%OUT *
%OUT * There were some LONG jumps which could have been SHORT.
%OUT *
ENDIF
ENDIF
ENDM
.XCREF SET_BACKWARD_JUMP
SET_BACKWARD_JUMP MACRO TARGET_LABEL
.XCREF BACKWARD_JUMP
IF1
IFNDEF TARGET_LABEL
BACKWARD_JUMP = 0
ENDIF
IFDEF TARGET_LABEL
BACKWARD_JUMP = 1
ENDIF
ENDIF
IF2
BACKWARD_JUMP = $ - OFFSET TARGET_LABEL GT 0
ENDIF
ENDM
.XCREF LJMP
LJMP MACRO TARGET_LABEL, LONG
LOCAL BYPASS
SET_BACKWARD_JUMP TARGET_LABEL
IF BACKWARD_JUMP
SET_SHORT_BACK TARGET_LABEL
ELSE
.XCREF SHORT_LABEL
SHORT_LABEL = 1
IFNB <LONG>
.XCREF LJMP_MAX_SHORT
LJMP_MAX_SHORT = 127 + OFFSET BYPASS - $
IS_LONG_NECESSARY TARGET_LABEL, LJMP_MAX_SHORT
SHORT_LABEL = 0
ENDIF
ENDIF
IF SHORT_LABEL
JMP SHORT TARGET_LABEL
ELSE
JMP TARGET_LABEL
ENDIF
IFE BACKWARD_JUMP
.SALL
.XCREF BYPASS
BYPASS:
SET_MACRO_EXPANSION
ENDIF
ENDM
.XCREF LCJMP
LCJMP MACRO CONDITION, TARGET_LABEL, LONG
LOCAL BYPASS
SET_BACKWARD_JUMP TARGET_LABEL
IF BACKWARD_JUMP
SET_SHORT_BACK TARGET_LABEL
ELSE
SHORT_LABEL = 1
IFNB <LONG>
.XCREF LCJMP_MAX_SHORT
LCJMP_MAX_SHORT = 127 + OFFSET BYPASS - $
IS_LONG_NECESSARY TARGET_LABEL, LCJMP_MAX_SHORT
SHORT_LABEL = 0
ENDIF
ENDIF
IF SHORT_LABEL
J&CONDITION TARGET_LABEL
ELSE
JN&CONDITION BYPASS
JMP TARGET_LABEL
ENDIF
IFE SHORT_LABEL AND BACKWARD_JUMP
IF SHORT_LABEL
.XCREF BYPASS
.SALL
ENDIF
BYPASS:
IF SHORT_LABEL
SET_MACRO_EXPANSION
ENDIF
ENDIF
ENDM
.XCREF LJCXZ
LJCXZ MACRO TARGET_LABEL, LONG
LOCAL BYPASS
SET_BACKWARD_JUMP TARGET_LABEL
IF BACKWARD_JUMP
SET_SHORT_BACK TARGET_LABEL
ELSE
SHORT_LABEL = 1
IFNB <LONG>
.XCREF LJXCZ_MAX_SHORT
LJXCZ_MAX_SHORT = 127 + OFFSET BYPASS - $
IS_LONG_NECESSARY TARGET_LABEL, LJXCZ_MAX_SHORT
SHORT_LABEL = 0
ENDIF
ENDIF
IF SHORT_LABEL
JCXZ TARGET_LABEL
ELSE
OR CX,CX
JNZ BYPASS
JMP TARGET_LABEL
ENDIF
IFE SHORT_LABEL AND BACKWARD_JUMP
IF SHORT_LABEL
.XCREF BYPASS
.SALL
ENDIF
BYPASS:
IF SHORT_LABEL
SET_MACRO_EXPANSION
ENDIF
ENDIF
ENDM
.XCREF LLOOP
LLOOP MACRO CONDITION, TARGET_LABEL, LONG
LOCAL BYPASS
SET_BACKWARD_JUMP TARGET_LABEL
IF BACKWARD_JUMP
SET_SHORT_BACK TARGET_LABEL
ELSE
SHORT_LABEL = 1
IFNB <LONG>
.XCREF LLOOP_MAX_SHORT
LLOOP_MAX_SHORT EQU 127 + OFFSET BYPASS - $
IS_LONG_NECESSARY TARGET_LABEL, LLOOP_MAX_SHORT
SHORT_LABEL = 0
ENDIF
ENDIF
IF SHORT_LABEL
LOOP&CONDITION TARGET_LABEL
ELSE
IFNB <CONDITION>
JN&CONDITION BYPASS
ENDIF
DEC CX
JZ BYPASS
JMP TARGET_LABEL
ENDIF
IFE SHORT_LABEL AND BACKWARD_JUMP
IF SHORT_LABEL
.XCREF BYPASS
.SALL
ENDIF
BYPASS:
IF SHORT_LABEL
SET_MACRO_EXPANSION
ENDIF
ENDIF
ENDM
.XCREF XINIT
XINIT MACRO
.XCREF L?CNT,S?CNT
L?CNT = 0
S?CNT = 0
ENDM
.XCREF PHASE_1_XINIT, PHASE_2_XINIT, XINIT_IF_NECESSARY
PHASE_1_XINIT = 1
PHASE_2_XINIT = 1
XINIT_IF_NECESSARY MACRO
IF1
IF PHASE_1_XINIT
XINIT
PHASE_1_XINIT = 0
ENDIF
ENDIF
IF2
IF PHASE_2_XINIT
XINIT
PHASE_2_XINIT = 0
ENDIF
ENDIF
ENDM
.XCREF XINC
XINC MACRO LABEL
XINIT_IF_NECESSARY
LABEL = LABEL+1
ENDM
.XCREF XSAVE,XPUSH,XPOP
XSAVE MACRO ENTRY,NUMBER
.XCREF S?&ENTRY
S?&ENTRY= NUMBER
ENDM
XPUSH MACRO
XINC L?CNT
XINC S?CNT
XSAVE %S?CNT,%L?CNT
ENDM
XPOP MACRO
S?CNT = S?CNT-1
ENDM
.XCREF XLBL,XLBLS,XLBLI
XLBL MACRO NUMBER
.XCREF L?&NUMBER
L?&NUMBER:
ENDM
XLBLS MACRO NUMBER
XLBL %S?&NUMBER
ENDM
XLBLI MACRO NUMBER
XINIT_IF_NECESSARY
XLBL %(S?&NUMBER&+1)
ENDM
.XCREF XJMP,XJMPS,XJMPI
XJMP MACRO NUMBER,LONG
LJMP L?&NUMBER, LONG
ENDM
XJMPS MACRO NUMBER,LONG
XJMP %S?&NUMBER,LONG
ENDM
XJMPI MACRO NUMBER,LONG
XJMP %(S?&NUMBER+1),LONG
ENDM
.XCREF XLP,XLPS
XLP MACRO CONDITION,NUMBER,LONG
LLOOP CONDITION,L?&NUMBER,LONG
ENDM
XLPS MACRO CONDITION,NUMBER,LONG
XLP CONDITION,%S?&NUMBER,LONG
ENDM
.XCREF XCJMP,XCJMPS,XCJMPI,XCXZJMP
XCJMP MACRO CONDITION,NUMBER,LONG
LCJMP CONDITION,L?&NUMBER,LONG
ENDM
XCJMPS MACRO CONDITION,NUMBER,LONG
XCJMP CONDITION,%S?&NUMBER,LONG
ENDM
XCJMPI MACRO CONDITION,NUMBER,LONG
XINIT_IF_NECESSARY
XCJMP CONDITION,%(S?&NUMBER+1),LONG
ENDM
XCXZJMP MACRO NUMBER,LONG
LJCXZ L?&NUMBER,LONG
ENDM
.XCREF XIFC,XANDIFC,COMPARE,XIF,XANDIF,XELSE,XENDIF
XIFC MACRO CONDITION,LONG
XPUSH
XCJMP N&CONDITION,%L?CNT,LONG
ENDM
XANDIFC MACRO CONDITION,LONG
XCJMP N&CONDITION,%L?CNT,LONG
ENDM
COMPARE MACRO VAL1,VAL2
IFNB <VAL2>
CMP VAL1,VAL2
ENDIF
IFB <VAL2>
AND VAL1,VAL1
ENDIF
ENDM
XIF MACRO VAL1,CONDITION,VAL2,LONG
COMPARE <VAL1>,<VAL2>
XIFC CONDITION,LONG
ENDM
XANDIF MACRO VAL1,CONDITION,VAL2,LONG
COMPARE <VAL1>,<VAL2>
XANDIFC CONDITION,LONG
ENDM
XELSE MACRO LONG
XINC L?CNT
XJMP %L?CNT,LONG
XLBLS %S?CNT
XSAVE %S?CNT,%L?CNT
ENDM
XENDIF MACRO
XLBLS %S?CNT
XPOP
ENDM
.XCREF XLOOP,XENDLP,XBEGIN,XEND,XNEXT,XCNEXTC,XCNEXT,XCEXITC,XEXIT
.XCREF XCEXIT,XWHILEC,XWHILE,XREPEAT,XUNTILC,XUNTIL,XFOR,XDEC
XLOOP MACRO
XPUSH
XLBL %L?CNT
XINC L?CNT
ENDM
XBEGIN MACRO
XPUSH
XLBL %L?CNT
XINC L?CNT
ENDM
XNEXT MACRO LONG
XJMPS %S?CNT,LONG
ENDM
XCNEXTC MACRO CONDITION,LONG
XCJMPS CONDITION,%S?CNT,LONG
ENDM
XCNEXT MACRO VAL1,CONDITION,VAL2,LONG
COMPARE <VAL1>,<VAL2>
XCNEXTC CONDITION,LONG
ENDM
XEXIT MACRO LONG
XJMPI %S?CNT,LONG
ENDM
XCEXITC MACRO CONDITION,LONG
XCJMPI CONDITION,%S?CNT,LONG
ENDM
XCEXIT MACRO VAL1,CONDITION,VAL2,LONG
COMPARE <VAL1>,<VAL2>
XCEXITC CONDITION,LONG
ENDM
XENDLP MACRO LONG
XJMPS %S?CNT,LONG
XLBLI %S?CNT
XPOP
ENDM
XEND MACRO
XLBLI %S?CNT
XPOP
ENDM
XWHILEC MACRO CONDITION,LONG
XLOOP
XCEXITC N&CONDITION,LONG
ENDM
XWHILE MACRO VAL1,CONDITION,VAL2,LONG
XLOOP
XCEXIT <VAL1>,N&CONDITION,<VAL2>,LONG
ENDM
XREPEAT MACRO
XLOOP
ENDM
XUNTILC MACRO CONDITION
XCJMPS N&CONDITION,%S?CNT
XLBLI %S?CNT
XPOP
ENDM
XUNTIL MACRO VAL1,CONDITION,VAL2
COMPARE <VAL1>,<VAL2>
XUNTILC CONDITION
ENDM
XFOR MACRO NOZERO,LONG
IFB <NOZERO>
XINIT_IF_NECESSARY
XCXZJMP %(L?CNT+2),LONG
ENDIF
XLOOP
ENDM
XDEC MACRO CONDITION,LONG
XLPS CONDITION,%S?CNT,LONG
XLBLI %S?CNT
XPOP
ENDM
.XCREF CALLSTR,FCBCALL,GETCALL
CALLSTR MACRO ROUTINE,STRING
MOV DX,OFFSET STRING
CALL ROUTINE
ENDM
GETCALL MACRO ROUTINE,STRING
MOV BX,OFFSET STRING
CALL ROUTINE
ENDM
FCBCALL MACRO ROUTINE,FCB,ERRORRTN
MOV DX,OFFSET FCB
CALL ROUTINE
IFNB <ERRORRTN>
JZ ERRORRTN
ENDIF
ENDM
.CREF
SET_MACRO_EXPANSION